package com.ruoyi.common.core.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 日志工具类
 */
public class LogUtils {
    public static Logger getLogger() {
        // 获取调用者的类名
        StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
        String className = stackTrace[2].getClassName();
        return LoggerFactory.getLogger(className);
    }

    public static void info(String message) {
        getLogger().info(message);
    }

    public static void info(String format, Object... args) {
        getLogger().info(format, args);
    }

    public static void debug(String message) {
        getLogger().debug(message);
    }

    public static void debug(String format, Object... args) {
        getLogger().debug(format, args);
    }

    public static void warn(String message) {
        getLogger().warn(message);
    }

    public static void warn(String format, Object... args) {
        getLogger().warn(format, args);
    }

    public static void error(String message) {
        getLogger().error(message);
    }

    public static void error(String format, Object... args) {
        getLogger().error(format, args);
    }

    public static void error(String message, Throwable t) {
        getLogger().error(message, t);
    }
}